import { DomSanitizer } from '@angular/platform-browser';
import { MatIconRegistry } from '@angular/material';

export const loadSvgResources = (ir: MatIconRegistry, ds: DomSanitizer) => {
    // svg icon 注册
    const imgDir = 'assets/img';
    const sidebarDir = `${imgDir}/sidebar`;
    const dayDir = `${imgDir}/days`;
    const avatarDir = `${imgDir}/avatar`;
    const iconDir = `${imgDir}/icons`;

    ir.addSvgIcon('move',
    ds.bypassSecurityTrustResourceUrl(`${iconDir}/move.svg`));
    ir.addSvgIcon('add',
    ds.bypassSecurityTrustResourceUrl(`${iconDir}/add.svg`));
    ir.addSvgIcon('delete',
    ds.bypassSecurityTrustResourceUrl(`${iconDir}/delete.svg`));

    ir.addSvgIcon('day',
        ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/day.svg`));
    ir.addSvgIcon('month',
        ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/month.svg`));
    ir.addSvgIcon('project',
        ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/project.svg`));
    ir.addSvgIcon('projects',
        ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/projects.svg`));
    ir.addSvgIcon('week',
        ds.bypassSecurityTrustResourceUrl(`${sidebarDir}/week.svg`));

    for (let i = 1; i <= 31; i++) {
        ir.addSvgIcon(`day${i}`,
        ds.bypassSecurityTrustResourceUrl(`${dayDir}/day${i}.svg`));
    }

    ir.addSvgIcon('unassigned',
        ds.bypassSecurityTrustResourceUrl(`${avatarDir}/unassigned.svg`));

    // 添加SVG图标集合
    // 使用方式  名字+:+ 在svg文件中的id ex: avatars:svg-1
    ir.addSvgIconSetInNamespace('avatars',
        ds.bypassSecurityTrustResourceUrl(`${avatarDir}/avatars.svg`));
};
